import pygame
from game import Game


class Button:
    def __init__(self, text: str, color, text_color, x: int, y: int, w: int, h: int, font_size: int):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.color = color
        self.text_color = text_color
        self.text = text
        self.rect = pygame.Rect(self.x, self.y, self.w, self.h)
        self.font = pygame.font.Font('font/datouren.ttf', font_size)
        self.botton_text = self.font.render(self.text, True, self.text_color)

    def display_button(self):
        pygame.draw.rect(Game.window, self.color, self.rect)
        Game.window.blit(self.botton_text, (self.rect.centerx - self.botton_text.get_width()
                                            / 2, self.rect.centery - self.botton_text.get_height() / 2))
